package com.huangsm.concurrence.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author huang
 * @PACKAGE_NAME com.huangsm.concurrence.demo
 * @PROJECT_NAME concurrence
 * @date 2019/2/15
 */
public class AtomicDemo {
    public static void main(String[] args) throws InterruptedException {
        final AtomicInteger value=new AtomicInteger(0);
        ExecutorService executorService =
                Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            Runnable task=()->{
                value.incrementAndGet();
            };
            executorService.execute(task);
        }
        executorService.shutdown();
        executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
        System.out.println(value.get());
    }
}
